package edu.mcw.rgd.clinminer.web.ui;

import com.vaadin.ui.Table;

import java.util.Arrays;

import com.vaadin.addon.jpacontainer.JPAContainer;
import com.vaadin.spring.roo.addon.annotations.RooVaadinEntityView;

import edu.mcw.rgd.clinminer.domain.Measurement;
import edu.mcw.rgd.clinminer.web.AbstractEntityView;
import edu.mcw.rgd.clinminer.web.EntityEditor;

@RooVaadinEntityView(formBackingObject = edu.mcw.rgd.clinminer.domain.Measurement.class)
public class MeasurementView extends AbstractEntityView<edu.mcw.rgd.clinminer.domain.Measurement> {

    @Override
    protected EntityEditor createForm() {
        return new MeasurementForm();
    }

    @Override
    protected void configureTable(Table table) {
        table.setContainerDataSource(getTableContainer());
        table.setVisibleColumns(getTableColumns());
		((JPAContainer<Measurement>) table.getContainerDataSource())
				.setSortProperty("participant", "participant.name");

        setupGeneratedColumns(table);
		table.setPageLength(25);
		table.setCacheRate(1);

    }

	@Override
	public Object[] getTableColumns() {
		System.out.println("Available properties to display: "
				+ Arrays.asList((super.getTableColumns())));

		String[] props = new String[] {
				"participant",
				"LOINCLabel",
				"value",
				"unit",
				"annotatedText",
				"documentSourceDate" };
		return props;
	}
}
